/*
 * @Author: SimonCK666 SimonYang223@163.com
 * @Date: 2022-05-08 19:10:24
 * @LastEditors: SimonCK666 SimonYang223@163.com
 * @LastEditTime: 2022-05-08 19:16:52
 * @FilePath: /golang-concept/L5_gorecursion/recursion.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import "fmt"

// 阶乘
func f1(a int) int {
	if a == 1 {
		// 退出条件
		return 1
	} else {
		// 调用自己
		return a * f1(a - 1)
	}
}

// 斐波那契
func f2(a int) int {
	if a == 1 || a == 2 {
		return 1
	} else {
		return f2(a - 1) * f2(a - 2)
	}
}

func main() {
	res := f1(5)
	fmt.Printf("res: %v\n", res)

	fres := f2(5)
	fmt.Printf("fres: %v\n", fres)
}